<template>
	<s-layout title="发送红包">
		<view class="pageBox">
			<!--发送红包-->
		
			<view class="item-box">
				<view class="title2">红包个数</view>
				<view class="flex align-center">
					<input placeholder="填写个数" v-model="num" class="money" type="number" />
				</view>
			</view>
		
			<view class="item-box">
				<view class="title2">总金额</view>
				<view class="flex align-center">
					<input placeholder="￥0.00" v-model="money" class="money" type="number" />
				</view>
			</view>
		
			<view class="item-box">
				<view class="title2">支付密码</view>
				<view class="flex align-center">
					<input placeholder="请输入支付密码" v-model="pay_pwd" class="money" type="password" />
				</view>
			</view>
		
			<view class="footer">
				<view class="big-money">￥{{money || '0.00'}}</view>
				<view class="btn" @click="handerSubmitMore()">塞进红包</view>
			</view>
		
		</view>
	</s-layout>
	
</template>

<script>
	import sheep from '@/sheep';
	export default {
		components: {

		},
		data() {
			return {
				num: '',
				money: '',
				content: '',
				data: {},
				type: '',
				id: 0,
				pay_pwd: '',
			}
		},
		onLoad(options) {
			this.id = options.id;
			
		},
		onShow() {

		},
		methods: {
			
			async handerSubmitMore() {
				//console.log("go submit", Number(this.money), Number(this.data.pv) );
				if (Number(this.num) <= 0) {
					uni.$u.toast('请输入红包个数');
					return false;
				}

				if (Number(this.money) <= 0) {
					uni.$u.toast('请输入总金额');
					return false;
				}

				if (!this.pay_pwd) {
					uni.$u.toast('请输入支付密码');
					return false;
				}
				let res = await sheep.$api.chat2.release({
					type_id: this.id,
					type:2,
					
					num: this.num,
					money: this.money,
					pay_pwd: this.pay_pwd,
				})
				if (res.code === 1) {
					let request = {
						num: this.num,
						money: this.money,
						id: res.data.id,
					};

					uni.setStorageSync('send-live-redpackage-more', request);

					uni.navigateBack({
						delta: 1
					})
				}

				// if(Number(this.money) > Number(this.data.pv)){
				// 	uni.$u.toast('当前pv: '+this.data.pv+', pv不够哦~');
				// 	return false;
				// }

				// uni.request({
				// 	url: '/redenvelope/release',
				// 	data: {
				// 		type_id: this.id,
				// 		num: this.num,
				// 		money: this.money,
				// 		pay_pwd: this.pay_pwd,
				// 	},
				// 	success: res => {
				// 		res = res.res;
				// 		if (res.code === 1) {
				// 			let request = {
				// 				num: this.num,
				// 				money: this.money,
				// 				id:res.data.id,
				// 			};

				// 			uni.setStorageSync('send-live-redpackage-more', request);

				// 			uni.navigateBack({
				// 				delta:1
				// 			})
				// 		}else{
				// 			uni.$u.toast(res.msg);
				// 		}
				// 	}
				// });

			}
		}
	}
</script>

<style scoped lang="scss">
	.item-box {
		background-color: #ffffff;
		border-radius: 20rpx;
		margin: 20rpx 24rpx 0rpx 24rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 36rpx 28rpx;

		.money {
			text-align: right;
		}

		.content {
			width: 646rpx;
		}
	}

	.title2 {
		font-size: 28rpx;
		font-family: PingFang SC;
		font-weight: 400;
		color: #292929;
		width: 200rpx;
	}

	.chat-name {
		font-size: 28rpx;
		font-family: PingFang SC;
		font-weight: 400;
		color: #999999;
	}

	.colorgrey {
		color: #999999;
	}



	.footer {
		display: flex;
		align-items: center;
		flex-direction: column;
		justify-content: center;
		margin-top: 80rpx;

	}

	.big-money {
		font-weight: bold;
		font-size: 60rpx;
		margin-bottom: 50rpx;
	}

	.btn {
		width: 300rpx;
		height: 80rpx;
		border-radius: 20rpx;
		background-color: red;
		color: white;
		display: flex;
		align-items: center;
		justify-content: center;
	}
</style>